#ifndef _CRT_FILE_H_
#define _CRT_FILE_H_

#include <crt_define.h>

#ifdef	__cplusplus
extern "C"
{
#endif


typedef unsigned long	file_path_len;
typedef const char*		file_path;


#if (TARGET_OS == OS_WINDOWS)
	typedef HANDLE            _fd_t;
	typedef	long long		   _fd_size;
	#define FILE_HANDLE		    HANDLE
	#define FILE_INVALID	    INVALID_HANDLE_VALUE
#elif (TARGET_OS == OS_POSIX)
	typedef  int              _fd_t;
	typedef	long				_fd_size;
	#define	FILE_HANDLE		int
	#define	FILE_INVALID	    (int)(-1)
#elif (TARGET_OS == OS_DARWIN)
	typedef  int              _fd_t;
	typedef	long	long			_fd_size;
	#define	FILE_HANDLE		int
	#define	FILE_INVALID	    (int)(-1)
#endif



_fd_t _file_open(const basic_tchar *filepath, int flags, int mode);
int _file_close(_fd_t fh);
_fd_size _file_lseek(_fd_t fh, _off_t offset, int whence);
int _file_read(_fd_t fh, void *buf, size_t size);
int _file_write(_fd_t fh, const void *buf, size_t size);
int64_t _file_fsize(_fd_t fh);


#ifdef	__cplusplus
}
#endif


#endif


